<template>
    <div class="goods-item" @click="itemClick">
        <img v-lazy="product.cover_url" alt="">
        <div class="goods-info">
            <p>{{product.title}}</p>
            <span class="price"><small>￥</small>{{product.price}}</span>
            <span class="collect">{{product.collects_count}}</span>
        </div>
    </div>
</template>
<script>
import {useRouter} from 'vue-router'
export default {
    props:{
        product:{
            type:Object,
            default(){
                return {}
            }
        }
    },
    setup(props){
        const router=useRouter()
        return{
            itemClick:()=>{
                console.log(props);
                router.push({path:'/detali',query:{id:props.product.id}})
            }
        }
    }
}
</script>
<style lang="less" scoped>
.goods-item{
    width: 46%;
    padding-bottom: 40px;
    position: relative;
    z-index: -1;
    img{
        width: 100%;
    }
    .goods-info{
        font-size: 12px;
        position: absolute;
        left: 0;
        right: 0;
        bottom: 5px;
        overflow: hidden;
        text-align: center;
        p{
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            margin-bottom: 3px;
        }
        .price{
            color: red;
            margin-right: 16px;
        }
        .collect{
            position: relative;
            &::after{
                content: '';
                position: absolute;
                left: -13px;
                top: 0;
                width: 14px;
                height: 14px;
                background: url('~assets/images/collect.png') ;
                background-size: 14px auto;
            }
        }
    }
}
</style>